import request from '@/utils/request'

const getOrdersList = (page, limit, key) => {
  return request('/orders/listWeb', {
    method: 'get',
    params: {
      page,
      limit,
      key
    }
  })
}

const getOrdersListByFuzzyQuery = (page, limit, key) => {
  return request('/orders/listByFuzzyQuery', {
    method: 'get',
    params: {
      page,
      limit,
      key
    }
  })
}

const deleteOrdersList = (orderNos) => {
  return request('/orders/delete', {
    method: 'post',
    data: {
      orderNos
    }
  })
}

const getOrdersById = (ordersId) => {
  return request({
    url: `/orders/info/${ordersId}`,
    method: 'get'
  })
}

const saveOrUpdateOrder = (ordersId, orders) => {
  return request(`/orders/${!ordersId ? 'save' : 'update'}`, {
    method: 'post',
    data: orders
  })
}

export { getOrdersList, getOrdersListByFuzzyQuery, deleteOrdersList, getOrdersById, saveOrUpdateOrder }
